<?php
include '../Module/newsModule.php';
$newModule=new newsModule();
if(isset($_REQUEST["action"])){
    switch ($_REQUEST["action"]){
        case "add":
            $category		=isset($_REQUEST["category"])?EndcodeStr($_REQUEST["category"]):"";
            $image		=isset($_REQUEST["image"])?EndcodeStr($_REQUEST["image"]):"";
            $img1		=isset($_REQUEST["img1"])?EndcodeStr($_REQUEST["img1"]):"";
            $img2		=isset($_REQUEST["img2"])?EndcodeStr($_REQUEST["img2"]):"";
            $img3		=isset($_REQUEST["img3"])?EndcodeStr($_REQUEST["img3"]):"";
            $img4		=isset($_REQUEST["img4"])?EndcodeStr($_REQUEST["img4"]):"";
            $img5		=isset($_REQUEST["img5"])?EndcodeStr($_REQUEST["img5"]):"";
            $title		=isset($_REQUEST["title"])?EndcodeStr($_REQUEST["title"]):"";
            $brief		=isset($_REQUEST["brief"])?EndcodeStr($_REQUEST["brief"]):"";
            $content		=isset($_REQUEST["des"])?EndcodeStr($_REQUEST["des"]):"";
            $second_title	=isset($_REQUEST["second_title"])?EndcodeStr($_REQUEST["second_title"]):"";
            $small_image	=isset($_REQUEST["small_image"])?EndcodeStr($_REQUEST["small_image"]):"";
            $album		=isset($_REQUEST["album"])?($_REQUEST["album"]):0;
            if($newModule->insertNew($category,$image,$small_image,$title,$second_title, $brief, $content,$img1,$img2,$img3,$img4,$img5,$album)){
                echo "true";
            }else{
                echo "Lỗi rồi<br/>".$newModule->error;
            }
            break;
        case "edit":
            $id                 =isset($_REQUEST["id"])?EndcodeStr($_REQUEST["id"]):"";
            $category		=isset($_REQUEST["category"])?EndcodeStr($_REQUEST["category"]):"";
            $image		=isset($_REQUEST["image"])?EndcodeStr($_REQUEST["image"]):"";
            $img1		=isset($_REQUEST["img1"])?EndcodeStr($_REQUEST["img1"]):"";
            $img2		=isset($_REQUEST["img2"])?EndcodeStr($_REQUEST["img2"]):"";
            $img3		=isset($_REQUEST["img3"])?EndcodeStr($_REQUEST["img3"]):"";
            $img4		=isset($_REQUEST["img4"])?EndcodeStr($_REQUEST["img4"]):"";
            $img5		=isset($_REQUEST["img5"])?EndcodeStr($_REQUEST["img5"]):"";
            $title		=isset($_REQUEST["title"])?EndcodeStr($_REQUEST["title"]):"";
            $brief		=isset($_REQUEST["brief"])?EndcodeStr($_REQUEST["brief"]):"";
            $content		=isset($_REQUEST["des"])?EndcodeStr($_REQUEST["des"]):"";
            $album		=isset($_REQUEST["album"])?($_REQUEST["album"]):0;
            $second_title	=isset($_REQUEST["second_title"])?EndcodeStr($_REQUEST["second_title"]):"";
            $small_image	=isset($_REQUEST["small_image"])?EndcodeStr($_REQUEST["small_image"]):"";
            if($newModule->updateNew($id,$category,$image,$small_image,$title,$second_title, $brief, $content,$img1,$img2,$img3,$img4,$img5,$album)){
                echo "true";
            }else{
                echo "Lỗi rồi<br/>".$newModule->error;
            }
            break;
            break;
        case "delete":
            $id		=isset($_REQUEST["id"])?EndcodeStr($_REQUEST["id"]):"";
            if($newModule->deleteNew($id)){
                echo "true";
            }else{
                echo "Lỗi rồi<br/>".$newModule->error;
            }
            break;
        case "restore":
            $id		=isset($_REQUEST["id"])?EndcodeStr($_REQUEST["id"]):"";
            if($newModule->restoreNew($id)){
                echo "true";
            }else{
                echo "Lỗi rồi<br/>".$newModule->error;
            }
            break;
    }    
}
?>
